
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="./jquery.js"></script>
    <script type="text/javascript" src="./stickytooltip.js"></script>
    <link href="stickytooltip.css" rel="stylesheet" type="text/css">
<title>Công nghệ Web & Ứng dụng</title>
</head>    
        
        
<?php

    require_once("mysql.php");
    require_once("function.php");
	require_once("phantrang.php");
    
    $danhsach_sp1 = Sanpham();
    //$danhsach_sp2 = Sanpham();
    
?>
<h2>Hiện Danh Sách Tất Cả Sản Phẩm</h2>

<table border="1">
   
     <?php
    	 // so tin trang dau
		$display = 10;
		// tinh tong so trang hien tai
		if(isset($_GET['page'])&&(int)$_GET['page']){
			$page = $_GET['page'];			
		}
		else
		{
			//neu chua xac dinh thi tim so trang
			$query = "SELECT COUNT(idSP) FROM sanpham";	
			$result = mysql_fetch_array($query);
			$record = $result[0];
			if($record > $display)
			{
				$page = ceil($record/$display);				
			}
			else
			{
				$page = 1;
			}
			
		}
		$start = (isset($_GET['start']) && (int)$_GET['start']>=0) ? $_GET['start'] : 0;
		$sql = "SELECT *FROM sanpham ORDER BY idSP LIMIT $start,$display";
		
		
	?>   
        
     <?php
        $stt=0;
        while($rows_moi = mysql_fetch_array($sql) )
        {
           
                    ?>
                    <td width='150' height='150'><?php echo $rows_moi['TenSP'];?><br/>
                <a href="Chitietsanpham.php?page=chitiet/../dtdd&idSP=<?php echo $rows_moi['idSP'];?>" data-tooltip="sticky<?=$stt;?>">
                <img src="upload/sanpham/hinhchinh/<?php echo $rows_moi['UrlHinh']?>" width="100" height="100" align="center"/>
                <?php
                    if($rows_moi['New']==0)
                    echo '<img src="img/new.gif" width="29" height="19" align="top">'; 
                ?>
                   <span type="text"><?php echo number_format($rows_moi['Gia'],2)?></span>VNĐ<br/>
                    <?php  $stt++;?>
                    <?php
                        if($stt%3==0)
                           echo"</tr><tr>";
              	  ?>
            
      <?php }?>
     
 </table>
 <?php
 	if($page>1) //neu can hien thi so trang
	{
		$next = $start + $display;
		$prev = $start - $display;
		$current = ($start/$display) +1;
		
		//Hien thi trang truoc 
		if($current!=1)
		{
			echo "<li><a href='sanpham.php?start=$prev&page=$page'>Previous</a></li>";
			
		}
	}
 ?>

   
       </div>
</html>